package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.BedDto;
import com.zzyl.dto.LoginDto;
import com.zzyl.entity.Bed;
import com.zzyl.mapper.BedMapper;
import com.zzyl.mapper.LoginMapper;
import com.zzyl.service.BedService;
import com.zzyl.service.LoginService;
import com.zzyl.utils.JwtUtil;
import com.zzyl.vo.BedVo;
import com.zzyl.vo.LoginVo;
import com.zzyl.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private LoginMapper loginMapper;

    @Override
    public UserVo login(LoginDto loginDto) {
        UserVo  user = loginMapper.login(loginDto);
        if(user!= null ){
            Map<String,Object> map = new HashMap<>();
            map.put("niceName",user.getNickName());
//密钥123
            String token = JwtUtil.createJWT("123", 3600, map);
            user.setUserToken(token);

        }
        return user;
    }
}

